Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
The parse-ms npm package is a utility for parsing milliseconds into an object with more readable time properties such as days, hours, minutes, and seconds. It is useful for converting a duration in milliseconds into a more human-readable format.
Parse milliseconds into an object
This feature allows you to convert a duration in milliseconds into an object with properties for days, hours, minutes, seconds, milliseconds, microseconds, and nanoseconds.
const parseMs = require('parse-ms');
const result = parseMs(1337000000);
console.log(result); // { days: 15, hours: 11, minutes: 23, seconds: 20, milliseconds: 0, microseconds: 0, nanoseconds: 0 }
Handle large durations
This feature demonstrates the ability to handle and accurately parse large durations, breaking them down into their respective time units.
const parseMs = require('parse-ms');
const result = parseMs(9876543210);
console.log(result); // { days: 114, hours: 1, minutes: 29, seconds: 3, milliseconds: 210, microseconds: 0, nanoseconds: 0 }
The 'ms' package is a utility for converting various time formats to milliseconds and vice versa. Unlike parse-ms, which focuses on breaking down milliseconds into an object with time properties, 'ms' can convert human-readable time formats (like '2 days', '1h', '5m') into milliseconds and back. It is more versatile in terms of input formats but does not provide the detailed breakdown that parse-ms does.
The 'pretty-ms' package is designed to convert milliseconds into a human-readable string format. It is similar to parse-ms in that it deals with milliseconds, but instead of returning an object, it returns a formatted string (e.g., '1d 3h 4m 5s'). It is useful for displaying durations in a user-friendly way but does not provide the detailed object breakdown that parse-ms offers.
Parse milliseconds into an object
npm install parse-ms
import parseMilliseconds from 'parse-ms';
parseMilliseconds(1337000001);
/*
{
days: 15,
hours: 11,
minutes: 23,
seconds: 20,
milliseconds: 1,
microseconds: 0,
nanoseconds: 0
}
*/
parseMilliseconds(1337000001n);
/*
{
days: 15n,
hours: 11n,
minutes: 23n,
seconds: 20n,
milliseconds: 1n,
microseconds: 0n,
nanoseconds: 0n
}
*/
FAQs
Parse milliseconds into an object
The npm package parse-ms receives a total of 5,215,512 weekly downloads. As such, parse-ms popularity was classified as popular.
We found that parse-ms demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.